<template>
  <!-- 查看 -->
  <View 
    v-if="formType === 'view'" 
    :orderNumber="query.orderNumber"
    :version="query.version" 
    @goBack="goBack" 
    :style="`height: ${contentHeight}px;`"
    :contentHeight="contentHeight" 
  />
  <!-- 编辑新增 -->
  <Update 
    v-if="['update', 'create'].includes(formType)" 
    :formType="formType" 
    @goBack="goBack" 
    :style="`height: ${contentHeight}px;`"
    :contentHeight="contentHeight"
  />
</template>
<script setup lang="ts">
import { useTagsViewStore } from '@/store/modules/tagsView'
import View from './view.vue'
import Update from './update.vue'

const formType = ref('') // 表单的类型：create - 新增；update - 修改
const query = useRoute().query as any
const contentHeight = ref(0)

// 关闭
const tagsViewStore = useTagsViewStore()
const { currentRoute, push } = useRouter() // 路由
const goBack = async () => {
  //获取当前路由并删除tagView
  tagsViewStore.delView(currentRoute.value)
  push('/orderManagement/orderManagement/marketing/marketingOrderAlter')
}

onMounted(() => {
  contentHeight.value = document.body.clientHeight - 125
  formType.value = query.type
})
</script>
